package com.xavier.book.spring_book_demo.model;

import lombok.Data;

@Data
public class PageRequest {
    private Integer currentPage = 1;
    private Integer pageSize = 10;

    public Integer getOffset() {
        int safeCurrent = (currentPage == null || currentPage < 1) ? 1 : currentPage;
        int safeSize = (pageSize == null || pageSize < 1) ? 10 : Math.min(pageSize, 100);
        return (safeCurrent - 1) * safeSize;
    }
}
